package com.isolate.run;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.PumpStreamHandler;
import org.springframework.http.HttpHeaders;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.WebSocketExtension;
import org.springframework.web.socket.WebSocketMessage;
import org.springframework.web.socket.WebSocketSession;

import java.io.*;
import java.net.InetSocketAddress;
import java.net.URI;
import java.security.Principal;
import java.util.List;
import java.util.Map;

/**
 * @author gaozhongbao
 * @date 2020/08/14
 **/
@Slf4j
public class Demo {

    public void test(){

    }



    public static void main(String[] args) throws Exception {
        byte[] bytes = new byte[1024 * 1024];
        InputStream inputStream = new ByteArrayInputStream(bytes);

        OutputStream outputStream = new ByteArrayOutputStream(1024 * 1024);

        OutputStream errorStream = new ByteArrayOutputStream(1024 * 1024);


        final CommandLine cmdLine = new CommandLine("/usr/local/Cellar/python/3.7.4/bin/python3.7");
        cmdLine.addArgument("/Users/koutadatomi/python/test.py");
        DefaultExecutor executor = new DefaultExecutor();
        executor.setStreamHandler(new PumpStreamHandler(System.err, System.out, System.in));

        int execute = executor.execute(cmdLine);
        log.info("execute:[{}]", execute);
    }

}
